class AuthClass:
    def __init__(self, name, pwd):
        self.name = name
        self.pwd = pwd

    def auth(self):
        if self.name == "python" and self.pwd == "123":
            return True
        else:
            return False


def auth_before(f):

    def inner(*args, **kwargs):
        if not user.auth():
            print("用户名或密码错误")
            return False
        else:
            return f(*args, **kwargs)

    return inner


@auth_before
def p1():
    return "this is p1 function"


# Press the green button in the gutter to run the script.
if __name__ == '__main__':

    user = AuthClass("python", "123")
    # result = auth_before(p1)

    print(p1())

# # See PyCharm help at https://www.jetbrains.com/help/pycharm/
# ————————————————
# 版权声明：本文为CSDN博主「Take^that」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
# 原文链接：https://blog.csdn.net/qq_37767455/article/details/119674570